/*     */ package dm.sql;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.dbaccess.DmMsgSend;
/*     */ import dm.jdbc.desc.DTypeInfo;
/*     */ import dm.jdbc.desc.LobDesc;
/*     */ import dm.jdbc.driver.DmdbBlob;
/*     */ import dm.jdbc.driver.DmdbCallableStatement_bs;
/*     */ import dm.jdbc.driver.DmdbConnection_bs;
/*     */ import java.io.Serializable;
/*     */ import java.sql.SQLException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TypeDescriptor
/*     */   implements Serializable
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*  29 */   LobDesc m_lobDesc = null;
/*  30 */   DTypeInfo m_dTypeInfo = null;
/*  31 */   SQLName m_sqlName = null;
/*  32 */   int m_objId = -1;
/*  33 */   int m_objVersion = -1;
/*     */   
/*  35 */   int m_outerId = 0;
/*  36 */   int m_outerVer = 0;
/*  37 */   int m_subId = 0;
/*  38 */   int m_cltnType = 0;
/*  39 */   int m_maxCnt = 0;
/*     */   
/*  41 */   int m_length = 0;
/*  42 */   int m_size = 0;
/*     */   
/*  44 */   DmdbConnection_bs m_conn = null;
/*  45 */   private String m_serverEncoding = null;
/*  46 */   public TypeDescriptor m_arrObj = null;
/*  47 */   public TypeDescriptor[] m_fieldsObj = null;
/*     */   
/*  49 */   byte[] m_descBuf = null;
/*     */   
/*     */   public TypeDescriptor(String fulName, DmdbConnection_bs conn) {
/*  52 */     this.m_sqlName = new SQLName(fulName);
/*  53 */     this.m_dTypeInfo = new DTypeInfo();
/*  54 */     this.m_conn = conn;
/*     */   }
/*     */   
/*     */   public TypeDescriptor(DmdbConnection_bs conn) {
/*  58 */     this.m_dTypeInfo = new DTypeInfo();
/*  59 */     this.m_sqlName = new SQLName(conn);
/*  60 */     this.m_conn = conn;
/*     */   }
/*     */   
/*     */   public DTypeInfo getDTypeInfo() {
/*  64 */     return this.m_dTypeInfo;
/*     */   }
/*     */   
/*     */   public void parseDescByName() throws SQLException
/*     */   {
/*  69 */     String sql = "BEGIN ? = SF_DESCRIBE_TYPE(?); END;";
/*  70 */     DmdbCallableStatement_bs cstmt = (DmdbCallableStatement_bs)this.m_conn
/*  71 */       .prepareCall(sql);
/*  72 */     cstmt.setString(2, this.m_sqlName.m_fulName);
/*  73 */     cstmt.registerOutParameter(1, 2004);
/*  74 */     cstmt.execute();
/*     */     
/*  76 */     DmdbBlob blob = (DmdbBlob)cstmt.getBlob(1);
/*  77 */     int lobLen = blob.getLobLen();
/*  78 */     byte[] buf = blob.getBytes(1L, lobLen);
/*     */     
/*  80 */     this.m_serverEncoding = this.m_conn.getServerEncoding();
/*  81 */     unpack(buf, 0);
/*     */     
/*  83 */     cstmt.close();
/*  84 */     cstmt = null;
/*     */   }
/*     */   
/*     */   public String getFulName() throws SQLException {
/*  88 */     return this.m_sqlName.getFulName();
/*     */   }
/*     */   
/*     */   public int getDType() {
/*  92 */     return this.m_dTypeInfo.getDType();
/*     */   }
/*     */   
/*     */   public String getServerEncoding() {
/*  96 */     return this.m_serverEncoding == null ? this.m_conn.getServerEncoding() : 
/*  97 */       this.m_serverEncoding;
/*     */   }
/*     */   
/*     */   public int getObjId() {
/* 101 */     return this.m_objId;
/*     */   }
/*     */   
/*     */   public int getObjVersion() {
/* 105 */     return this.m_objVersion;
/*     */   }
/*     */   
/*     */   public int getStaticArrayLength() {
/* 109 */     return this.m_length;
/*     */   }
/*     */   
/*     */   public int getStrctMemSize() {
/* 113 */     return this.m_size;
/*     */   }
/*     */   
/*     */   public int getOuterId() {
/* 117 */     return this.m_outerId;
/*     */   }
/*     */   
/*     */   public int getCltnType() {
/* 121 */     return this.m_cltnType;
/*     */   }
/*     */   
/*     */   public int getOuterVer() {
/* 125 */     return this.m_outerVer;
/*     */   }
/*     */   
/*     */   public int getSubId() {
/* 129 */     return this.m_subId;
/*     */   }
/*     */   
/*     */   public int getMaxCnt() {
/* 133 */     return this.m_maxCnt;
/*     */   }
/*     */   
/*     */   private static int getPackSize(TypeDescriptor typeDesc) throws SQLException {
/* 137 */     int len = 0;
/*     */     
/* 139 */     switch (typeDesc.m_dTypeInfo.getDType())
/*     */     {
/*     */     case 117: 
/*     */     case 122: 
/* 143 */       return getPackArraySize(typeDesc);
/*     */     
/*     */     case 119: 
/* 146 */       return getPackClassSize(typeDesc);
/*     */     
/*     */     case 121: 
/* 149 */       return getPackRecordSize(typeDesc);
/*     */     }
/*     */     
/*     */     
/* 153 */     len += 4;
/*     */     
/*     */ 
/* 156 */     len += 4;
/*     */     
/*     */ 
/* 159 */     len += 4;
/*     */     
/* 161 */     return len;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private static void pack(TypeDescriptor typeDesc, DmMsgSend msg)
/*     */     throws SQLException
/*     */   {
/* 176 */     switch (typeDesc.m_dTypeInfo.getDType())
/*     */     {
/*     */     case 117: 
/*     */     case 122: 
/* 180 */       packArray(typeDesc, msg);
/* 181 */       return;
/*     */     case 119: 
/* 183 */       packClass(typeDesc, msg);
/* 184 */       return;
/*     */     case 121: 
/* 186 */       packRecord(typeDesc, msg);
/* 187 */       return;
/*     */     }
/*     */     
/*     */     
/* 191 */     msg.setInt(typeDesc.m_dTypeInfo.getDType());
/*     */     
/*     */ 
/* 194 */     msg.setInt(typeDesc.m_dTypeInfo.getPrec());
/*     */     
/*     */ 
/* 197 */     msg.setInt(typeDesc.m_dTypeInfo.getScale());
/*     */   }
/*     */   
/*     */   public static int getPackArraySize(TypeDescriptor arrDesc) throws SQLException
/*     */   {
/* 202 */     int len = 0;
/*     */     
/*     */ 
/* 205 */     len += 4;
/*     */     
/*     */ 
/* 208 */     String name = arrDesc.m_sqlName.m_name;
/* 209 */     len += 2;
/*     */     
/* 211 */     String serverEncoding = arrDesc.getServerEncoding();
/* 212 */     byte[] ret = Convertion.getBytes(name, serverEncoding);
/* 213 */     len += ret.length;
/*     */     
/*     */ 
/* 216 */     len += 4;
/*     */     
/*     */ 
/* 219 */     len += 4;
/*     */     
/*     */ 
/* 222 */     len += 4;
/*     */     
/* 224 */     len += getPackSize(arrDesc.m_arrObj);
/*     */     
/* 226 */     return len;
/*     */   }
/*     */   
/*     */ 
/*     */   public static void packArray(TypeDescriptor arrDesc, DmMsgSend msg)
/*     */     throws SQLException
/*     */   {
/* 233 */     msg.setInt(arrDesc.m_dTypeInfo.getDType());
/*     */     
/*     */ 
/* 236 */     String name = arrDesc.m_sqlName.m_name;
/* 237 */     msg.setShort(name.length());
/*     */     
/* 239 */     String serverEncoding = arrDesc.getServerEncoding();
/* 240 */     msg.setString(name, serverEncoding);
/*     */     
/*     */ 
/* 243 */     msg.setInt(arrDesc.m_objId);
/*     */     
/*     */ 
/* 246 */     msg.setInt(arrDesc.m_objVersion);
/*     */     
/*     */ 
/* 249 */     msg.setInt(arrDesc.m_length);
/*     */     
/* 251 */     pack(arrDesc.m_arrObj, msg);
/*     */   }
/*     */   
/*     */ 
/*     */   public static void packRecord(TypeDescriptor strctDesc, DmMsgSend msg)
/*     */     throws SQLException
/*     */   {
/* 258 */     msg.setInt(strctDesc.m_dTypeInfo.getDType());
/*     */     
/*     */ 
/* 261 */     String name = strctDesc.m_sqlName.m_name;
/* 262 */     msg.setShort(name.length());
/*     */     
/* 264 */     String serverEncoding = strctDesc.getServerEncoding();
/* 265 */     msg.setString(name, serverEncoding);
/*     */     
/*     */ 
/* 268 */     msg.setInt(strctDesc.m_objId);
/*     */     
/*     */ 
/* 271 */     msg.setInt(strctDesc.m_objVersion);
/*     */     
/*     */ 
/* 274 */     msg.setShort(strctDesc.m_size);
/*     */     
/* 276 */     for (int i = 0; i < strctDesc.m_size; i++) {
/* 277 */       pack(strctDesc.m_fieldsObj[i], msg);
/*     */     }
/*     */   }
/*     */   
/*     */   public static int getPackRecordSize(TypeDescriptor strctDesc) throws SQLException {
/* 282 */     int len = 0;
/*     */     
/*     */ 
/* 285 */     len += 4;
/*     */     
/*     */ 
/* 288 */     String name = strctDesc.m_sqlName.m_name;
/* 289 */     len += 2;
/*     */     
/* 291 */     String serverEncoding = strctDesc.getServerEncoding();
/* 292 */     byte[] ret = Convertion.getBytes(name, serverEncoding);
/* 293 */     len += ret.length;
/*     */     
/*     */ 
/* 296 */     len += 4;
/*     */     
/*     */ 
/* 299 */     len += 4;
/*     */     
/*     */ 
/* 302 */     len += 2;
/*     */     
/* 304 */     for (int i = 0; i < strctDesc.m_size; i++) {
/* 305 */       len += getPackSize(strctDesc.m_fieldsObj[i]);
/*     */     }
/* 307 */     return len;
/*     */   }
/*     */   
/*     */   public static int getPackClassSize(TypeDescriptor strctDesc) throws SQLException
/*     */   {
/* 312 */     int len = 0;
/*     */     
/*     */ 
/* 315 */     len += 4;
/*     */     
/*     */ 
/* 318 */     String name = strctDesc.m_sqlName.m_name;
/* 319 */     len += 2;
/*     */     
/* 321 */     String serverEncoding = strctDesc.getServerEncoding();
/* 322 */     byte[] ret = Convertion.getBytes(name, serverEncoding);
/* 323 */     len += ret.length;
/*     */     
/*     */ 
/* 326 */     len += 4;
/*     */     
/*     */ 
/* 329 */     len += 4;
/*     */     
/* 331 */     if (strctDesc.m_objId == 4)
/*     */     {
/* 333 */       len += 4;
/*     */       
/*     */ 
/* 336 */       len += 4;
/*     */       
/*     */ 
/* 339 */       len += 2;
/*     */     }
/*     */     
/* 342 */     return len;
/*     */   }
/*     */   
/*     */ 
/*     */   public static void packClass(TypeDescriptor strctDesc, DmMsgSend msg)
/*     */     throws SQLException
/*     */   {
/* 349 */     msg.setInt(strctDesc.m_dTypeInfo.getDType());
/*     */     
/*     */ 
/* 352 */     String name = strctDesc.m_sqlName.m_name;
/* 353 */     msg.setShort(name.length());
/*     */     
/* 355 */     String serverEncoding = strctDesc.getServerEncoding();
/* 356 */     msg.setString(name, serverEncoding);
/*     */     
/*     */ 
/* 359 */     msg.setInt(strctDesc.m_objId);
/*     */     
/*     */ 
/* 362 */     msg.setInt(strctDesc.m_objVersion);
/*     */     
/* 364 */     if (strctDesc.m_objId == 4)
/*     */     {
/* 366 */       msg.setInt(strctDesc.m_outerId);
/*     */       
/*     */ 
/* 369 */       msg.setInt(strctDesc.m_outerVer);
/*     */       
/*     */ 
/* 372 */       msg.setShort(strctDesc.m_subId);
/*     */     }
/*     */   }
/*     */   
/*     */   public static int packClass(TypeDescriptor strctDesc, DmMsgSend msg, int offset)
/*     */     throws SQLException
/*     */   {
/* 379 */     int offsetDes = offset;
/*     */     
/*     */ 
/* 382 */     msg.setInt(strctDesc.m_dTypeInfo.getDType(), offsetDes);
/* 383 */     offsetDes += 4;
/*     */     
/*     */ 
/* 386 */     String name = strctDesc.m_sqlName.m_name;
/* 387 */     msg.setShort(name.length(), offsetDes);
/* 388 */     offsetDes += 2;
/*     */     
/* 390 */     String serverEncoding = strctDesc.getServerEncoding();
/* 391 */     offsetDes += msg.setString(name, serverEncoding, offsetDes);
/* 392 */     offsetDes += name.length();
/*     */     
/*     */ 
/* 395 */     msg.setInt(strctDesc.m_objId, offsetDes);
/* 396 */     offsetDes += 4;
/*     */     
/*     */ 
/* 399 */     msg.setInt(strctDesc.m_objVersion, offsetDes);
/* 400 */     offsetDes += 4;
/*     */     
/* 402 */     if (strctDesc.m_objId == 4)
/*     */     {
/* 404 */       msg.setInt(strctDesc.m_outerId, offsetDes);
/* 405 */       offsetDes += 4;
/*     */       
/*     */ 
/* 408 */       msg.setInt(strctDesc.m_outerVer, offsetDes);
/* 409 */       offsetDes += 4;
/*     */       
/*     */ 
/* 412 */       msg.setShort(strctDesc.m_subId, offsetDes);
/* 413 */       offsetDes += 2;
/*     */       
/* 415 */       return offsetDes;
/*     */     }
/*     */     
/* 418 */     return offsetDes;
/*     */   }
/*     */   
/*     */   public int unpack(byte[] buf, int offset)
/*     */     throws SQLException
/*     */   {
/* 424 */     int offsetDes = offset;
/*     */     
/*     */ 
/* 427 */     int dtype = Convertion.getInt(buf, offsetDes);
/* 428 */     offsetDes += 4;
/* 429 */     this.m_dTypeInfo.setDType(dtype);
/*     */     
/* 431 */     switch (dtype) {
/*     */     case 117: 
/*     */     case 122: 
/* 434 */       return unpackArray(buf, offsetDes);
/*     */     
/*     */     case 119: 
/* 437 */       return unpackClass(buf, offsetDes);
/*     */     
/*     */     case 121: 
/* 440 */       return unpackRecord(buf, offsetDes);
/*     */     }
/*     */     
/*     */     
/* 444 */     int tmp = Convertion.getInt(buf, offsetDes);
/* 445 */     this.m_dTypeInfo.setPrec(tmp);
/* 446 */     offsetDes += 4;
/*     */     
/*     */ 
/* 449 */     tmp = Convertion.getInt(buf, offsetDes);
/* 450 */     this.m_dTypeInfo.setScale(tmp);
/* 451 */     offsetDes += 4;
/*     */     
/* 453 */     return offsetDes;
/*     */   }
/*     */   
/*     */   private int unpackArray(byte[] buf, int offset) throws SQLException {
/* 457 */     int offsetDes = offset;
/*     */     
/*     */ 
/* 460 */     int tmpLen = Convertion.getShort(buf, offsetDes);
/* 461 */     offsetDes += 2;
/*     */     
/* 463 */     String tmpName = Convertion.getString(buf, offsetDes, tmpLen, 
/* 464 */       getServerEncoding());
/* 465 */     offsetDes += tmpLen;
/*     */     
/* 467 */     this.m_sqlName.m_name = tmpName;
/*     */     
/*     */ 
/* 470 */     this.m_sqlName.m_schId = Convertion.getInt(buf, offsetDes);
/* 471 */     offsetDes += 4;
/*     */     
/*     */ 
/* 474 */     this.m_sqlName.m_packId = Convertion.getInt(buf, offsetDes);
/* 475 */     offsetDes += 4;
/*     */     
/*     */ 
/* 478 */     this.m_objId = Convertion.getInt(buf, offsetDes);
/* 479 */     offsetDes += 4;
/*     */     
/*     */ 
/* 482 */     this.m_objVersion = Convertion.getInt(buf, offsetDes);
/* 483 */     offsetDes += 4;
/*     */     
/*     */ 
/* 486 */     if (this.m_dTypeInfo.getDType() == 117) {
/* 487 */       this.m_length = 0;
/*     */     } else
/* 489 */       this.m_length = Convertion.getInt(buf, offsetDes);
/* 490 */     offsetDes += 4;
/*     */     
/*     */ 
/* 493 */     int descLen = 0;
/* 494 */     this.m_arrObj = new TypeDescriptor(this.m_conn);
/* 495 */     descLen = this.m_arrObj.unpack(buf, offsetDes);
/* 496 */     return descLen;
/*     */   }
/*     */   
/*     */   private int unpackRecord(byte[] buf, int offset) throws SQLException {
/* 500 */     int offsetDes = offset;
/*     */     
/*     */ 
/* 503 */     int tmpLen = Convertion.getShort(buf, offsetDes);
/* 504 */     offsetDes += 2;
/*     */     
/* 506 */     String tmpName = Convertion.getString(buf, offsetDes, tmpLen, 
/* 507 */       getServerEncoding());
/* 508 */     offsetDes += tmpLen;
/*     */     
/* 510 */     this.m_sqlName.m_name = tmpName;
/*     */     
/*     */ 
/* 513 */     this.m_sqlName.m_schId = Convertion.getInt(buf, offsetDes);
/* 514 */     offsetDes += 4;
/*     */     
/*     */ 
/* 517 */     this.m_sqlName.m_packId = Convertion.getInt(buf, offsetDes);
/* 518 */     offsetDes += 4;
/*     */     
/*     */ 
/* 521 */     this.m_objId = Convertion.getInt(buf, offsetDes);
/* 522 */     offsetDes += 4;
/*     */     
/*     */ 
/* 525 */     this.m_objVersion = Convertion.getInt(buf, offsetDes);
/* 526 */     offsetDes += 4;
/*     */     
/*     */ 
/* 529 */     this.m_size = Convertion.getShort(buf, offsetDes);
/* 530 */     offsetDes += 2;
/*     */     
/* 532 */     this.m_fieldsObj = new TypeDescriptor[this.m_size];
/* 533 */     for (int i = 0; i < this.m_size; i++) {
/* 534 */       this.m_fieldsObj[i] = new TypeDescriptor(this.m_conn);
/* 535 */       offsetDes = this.m_fieldsObj[i].unpack(buf, offsetDes);
/*     */     }
/*     */     
/* 538 */     return offsetDes;
/*     */   }
/*     */   
/*     */   private int unpackClnt_nestTab(byte[] buf, int offsetDes)
/*     */     throws SQLException
/*     */   {
/* 544 */     this.m_maxCnt = Convertion.getInt(buf, offsetDes);
/* 545 */     offsetDes += 4;
/*     */     
/* 547 */     this.m_arrObj = new TypeDescriptor(this.m_conn);
/*     */     
/* 549 */     return this.m_arrObj.unpack(buf, offsetDes);
/*     */   }
/*     */   
/*     */   private int unpackClnt(byte[] buf, int offset) throws SQLException
/*     */   {
/* 554 */     int offsetDes = offset;
/*     */     
/*     */ 
/* 557 */     this.m_outerId = Convertion.getInt(buf, offsetDes);
/* 558 */     offsetDes += 4;
/*     */     
/*     */ 
/* 561 */     this.m_outerVer = Convertion.getInt(buf, offsetDes);
/* 562 */     offsetDes += 4;
/*     */     
/*     */ 
/* 565 */     this.m_subId = Convertion.getShort(buf, offsetDes);
/* 566 */     offsetDes += 2;
/*     */     
/*     */ 
/* 569 */     this.m_cltnType = Convertion.getShort(buf, offsetDes);
/* 570 */     offsetDes += 2;
/*     */     
/* 572 */     switch (this.m_cltnType) {
/*     */     case 3: 
/* 574 */       DBError.throwUnsupportedSQLException();
/* 575 */       break;
/*     */     
/*     */     case 1: 
/*     */     case 2: 
/* 579 */       offsetDes = unpackClnt_nestTab(buf, offsetDes);
/*     */     }
/*     */     
/*     */     
/* 583 */     return offsetDes;
/*     */   }
/*     */   
/*     */   private int unpackClass(byte[] buf, int offset) throws SQLException {
/* 587 */     int offsetDes = offset;
/*     */     
/*     */ 
/* 590 */     int tmpLen = Convertion.getShort(buf, offsetDes);
/* 591 */     offsetDes += 2;
/*     */     
/* 593 */     String tmpName = Convertion.getString(buf, offsetDes, tmpLen, 
/* 594 */       getServerEncoding());
/* 595 */     offsetDes += tmpLen;
/*     */     
/* 597 */     this.m_sqlName.m_name = tmpName;
/*     */     
/*     */ 
/* 600 */     this.m_sqlName.m_schId = Convertion.getInt(buf, offsetDes);
/* 601 */     offsetDes += 4;
/*     */     
/*     */ 
/* 604 */     this.m_sqlName.m_packId = Convertion.getInt(buf, offsetDes);
/* 605 */     offsetDes += 4;
/*     */     
/*     */ 
/* 608 */     this.m_objId = Convertion.getInt(buf, offsetDes);
/* 609 */     offsetDes += 4;
/*     */     
/*     */ 
/* 612 */     this.m_objVersion = Convertion.getInt(buf, offsetDes);
/* 613 */     offsetDes += 4;
/*     */     
/*     */ 
/* 616 */     if (this.m_objId == 4) {
/* 617 */       offsetDes = unpackClnt(buf, offsetDes);
/*     */     }
/*     */     else {
/* 620 */       this.m_size = Convertion.getShort(buf, offsetDes);
/* 621 */       offsetDes += 2;
/*     */       
/* 623 */       this.m_fieldsObj = new TypeDescriptor[this.m_size];
/* 624 */       for (int i = 0; i < this.m_size; i++) {
/* 625 */         this.m_fieldsObj[i] = new TypeDescriptor(this.m_conn);
/* 626 */         offsetDes = this.m_fieldsObj[i].unpack(buf, offsetDes);
/*     */       }
/*     */     }
/*     */     
/* 630 */     return offsetDes;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen_array(TypeDescriptor desc) throws SQLException {
/* 634 */     int offset = 0;
/*     */     
/*     */ 
/* 637 */     offset += 2;
/*     */     
/*     */ 
/* 640 */     offset += 4;
/*     */     
/*     */ 
/* 643 */     offset += calcChkDescLen(desc.m_arrObj);
/*     */     
/* 645 */     return offset;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen_record(TypeDescriptor desc) throws SQLException {
/* 649 */     int offset = 0;
/*     */     
/*     */ 
/* 652 */     offset += 2;
/*     */     
/*     */ 
/* 655 */     offset += 2;
/*     */     
/*     */ 
/* 658 */     for (int i = 0; i < desc.m_size; i++) {
/* 659 */       offset += calcChkDescLen(desc.m_fieldsObj[i]);
/*     */     }
/* 661 */     return offset;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen_class_normal(TypeDescriptor desc) throws SQLException
/*     */   {
/* 666 */     int offset = 0;
/*     */     
/*     */ 
/* 669 */     offset += 2;
/*     */     
/*     */ 
/* 672 */     for (int i = 0; i < desc.m_size; i++) {
/* 673 */       offset += calcChkDescLen(desc.m_fieldsObj[i]);
/*     */     }
/* 675 */     return offset;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen_class_cnlt(TypeDescriptor desc) throws SQLException
/*     */   {
/* 680 */     int offset = 0;
/*     */     
/* 682 */     switch (desc.getDType()) {
/*     */     case 3: 
/* 684 */       DBError.throwUnsupportedSQLException();
/* 685 */       break;
/*     */     
/*     */ 
/*     */     case 2: 
/* 689 */       offset += 4;
/*     */       
/*     */ 
/* 692 */       offset += calcChkDescLen(desc.m_arrObj);
/* 693 */       break;
/*     */     
/*     */     case 1: 
/* 696 */       offset = calcChkDescLen(desc);
/*     */     }
/*     */     
/*     */     
/* 700 */     return offset;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen_class(TypeDescriptor desc) throws SQLException {
/* 704 */     int offset = 0;
/*     */     
/*     */ 
/* 707 */     offset += 2;
/*     */     
/*     */ 
/* 710 */     offset++;
/*     */     
/* 712 */     if (desc.m_objId == 4) {
/* 713 */       offset += calcChkDescLen_class_cnlt(desc);
/*     */     } else {
/* 715 */       offset += calcChkDescLen_class_normal(desc);
/*     */     }
/* 717 */     return offset;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen_buildin(TypeDescriptor desc) {
/* 721 */     int offset = 0;
/*     */     
/*     */ 
/* 724 */     offset += 2;
/*     */     
/*     */ 
/* 727 */     offset += 2;
/*     */     
/*     */ 
/* 730 */     offset += 2;
/*     */     
/* 732 */     return offset;
/*     */   }
/*     */   
/*     */   private int calcChkDescLen(TypeDescriptor desc) throws SQLException {
/* 736 */     int offset = 0;
/*     */     
/* 738 */     switch (desc.getDType()) {
/*     */     case 117: 
/*     */     case 122: 
/* 741 */       offset = calcChkDescLen_array(desc);
/* 742 */       break;
/*     */     
/*     */     case 121: 
/* 745 */       offset = calcChkDescLen_record(desc);
/* 746 */       break;
/*     */     
/*     */     case 119: 
/* 749 */       offset = calcChkDescLen_class(desc);
/* 750 */       break;
/*     */     case 118: case 120: 
/*     */     default: 
/* 753 */       offset = calcChkDescLen_buildin(desc);
/*     */     }
/*     */     
/*     */     
/* 757 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc_array(int offset, TypeDescriptor desc)
/*     */     throws SQLException
/*     */   {
/* 763 */     Convertion.setShort(this.m_descBuf, offset, (short)117);
/* 764 */     offset += 2;
/*     */     
/*     */ 
/* 767 */     Convertion.setInt(this.m_descBuf, offset, desc.m_length);
/* 768 */     offset += 4;
/*     */     
/*     */ 
/* 771 */     offset = makeChkDesc(offset, desc.m_arrObj);
/*     */     
/* 773 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc_record(int offset, TypeDescriptor desc)
/*     */     throws SQLException
/*     */   {
/* 779 */     Convertion.setShort(this.m_descBuf, offset, (short)121);
/* 780 */     offset += 2;
/*     */     
/*     */ 
/* 783 */     Convertion.setShort(this.m_descBuf, offset, (short)desc.m_size);
/* 784 */     offset += 2;
/*     */     
/* 786 */     for (int i = 0; i < desc.m_size; i++) {
/* 787 */       offset = makeChkDesc(offset, desc.m_fieldsObj[i]);
/*     */     }
/* 789 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc_buildin(int offset, TypeDescriptor desc)
/*     */   {
/* 794 */     short dtype = (short)desc.getDType();
/* 795 */     short prec = 0;
/* 796 */     short scale = 0;
/*     */     
/* 798 */     if (dtype != 12)
/*     */     {
/* 800 */       prec = (short)desc.getDTypeInfo().getPrec();
/* 801 */       scale = (short)desc.getDTypeInfo().getScale();
/*     */     }
/*     */     
/*     */ 
/* 805 */     Convertion.setShort(this.m_descBuf, offset, dtype);
/* 806 */     offset += 2;
/*     */     
/*     */ 
/* 809 */     Convertion.setShort(this.m_descBuf, offset, prec);
/* 810 */     offset += 2;
/*     */     
/*     */ 
/* 813 */     Convertion.setShort(this.m_descBuf, offset, scale);
/* 814 */     offset += 2;
/*     */     
/* 816 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc_class_normal(int offset, TypeDescriptor desc)
/*     */     throws SQLException
/*     */   {
/* 822 */     Convertion.setShort(this.m_descBuf, offset, (short)desc.m_size);
/* 823 */     offset += 2;
/*     */     
/*     */ 
/* 826 */     for (int i = 0; i < desc.m_size; i++) {
/* 827 */       offset = makeChkDesc(offset, desc.m_fieldsObj[i]);
/*     */     }
/* 829 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc_class_clnt(int offset, TypeDescriptor desc)
/*     */     throws SQLException
/*     */   {
/* 835 */     Convertion.setShort(this.m_descBuf, offset, (short)desc.m_cltnType);
/* 836 */     offset += 2;
/*     */     
/*     */ 
/* 839 */     switch (desc.m_cltnType) {
/*     */     case 3: 
/* 841 */       DBError.throwUnsupportedSQLException();
/* 842 */       break;
/*     */     
/*     */ 
/*     */     case 2: 
/* 846 */       Convertion.setInt(this.m_descBuf, offset, desc.getMaxCnt());
/* 847 */       offset += 4;
/*     */       
/*     */ 
/* 850 */       offset = makeChkDesc_array(offset, desc.m_arrObj);
/* 851 */       break;
/*     */     
/*     */     case 1: 
/* 854 */       offset = makeChkDesc_array(offset, desc.m_arrObj);
/*     */     }
/*     */     
/*     */     
/* 858 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc_class(int offset, TypeDescriptor desc)
/*     */     throws SQLException
/*     */   {
/* 864 */     Convertion.setShort(this.m_descBuf, offset, (short)119);
/* 865 */     offset += 2;
/*     */     
/*     */ 
/* 868 */     boolean isClnt = false;
/* 869 */     if (this.m_objId == 4) {
/* 870 */       isClnt = true;
/*     */     }
/* 872 */     if (isClnt) {
/* 873 */       Convertion.setByte(this.m_descBuf, offset, (byte)1);
/*     */     } else
/* 875 */       Convertion.setByte(this.m_descBuf, offset, (byte)0);
/* 876 */     offset++;
/*     */     
/*     */ 
/* 879 */     if (isClnt) {
/* 880 */       offset = makeChkDesc_class_clnt(offset, desc);
/*     */     } else {
/* 882 */       offset = makeChkDesc_class_normal(offset, desc);
/*     */     }
/* 884 */     return offset;
/*     */   }
/*     */   
/*     */   private int makeChkDesc(int offset, TypeDescriptor subDesc) throws SQLException
/*     */   {
/* 889 */     switch (subDesc.getDType()) {
/*     */     case 117: 
/*     */     case 122: 
/* 892 */       offset = makeChkDesc_array(offset, subDesc);
/* 893 */       break;
/*     */     
/*     */     case 121: 
/* 896 */       offset = makeChkDesc_record(offset, subDesc);
/* 897 */       break;
/*     */     
/*     */     case 119: 
/* 900 */       offset = makeChkDesc_class(offset, subDesc);
/* 901 */       break;
/*     */     case 118: case 120: 
/*     */     default: 
/* 904 */       offset = makeChkDesc_buildin(offset, subDesc);
/*     */     }
/*     */     
/*     */     
/* 908 */     return offset;
/*     */   }
/*     */   
/*     */   byte[] getClassDescChkInfo() throws SQLException {
/* 912 */     if (this.m_descBuf != null) {
/* 913 */       return this.m_descBuf;
/*     */     }
/* 915 */     int len = calcChkDescLen(this);
/* 916 */     this.m_descBuf = new byte[len];
/*     */     
/* 918 */     makeChkDesc(0, this);
/* 919 */     return this.m_descBuf;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\sql\TypeDescriptor.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */